package com.zjsru.dailytest;

/**
 * @Author: likew
 * @Date: 2022/2/22
 * <p>
 * 连续字符
 * <p>
 * 输入：s = "leetcode"
 * 输出：2
 * 解释：子字符串 "ee" 长度为 2 ，只包含字符 'e' 。
 */
public class maxPower {
    public int maxPower(String s) {
        int n = s.length();
        int res = 0;
        for (int i = 0; i < n; ) {
            int j = i;
            while (j < n && s.charAt(i) == s.charAt(j)) {
                j++;
            }
            res = Math.max(res, j - i);
            i = j;
        }
        return res;
    }

    public static void main(String[] args) {
        maxPower maxPower = new maxPower();
        String s = "leetcode";
        System.out.println(maxPower.maxPower(s));
    }
}
